/*
 * @Descripttion: GGB
 * @version: 1.0
 * @Author: GGB
 * @Date: 2021-08-20 16:24:51
 * @LastEditors: GGB
 * @LastEditTime: 2021-08-20 22:11:09
 */
import 'package:flutter_data_center/model/attendance/grade_attendance_model.dart';
import 'package:flutter_data_center/model/common/menu_model.dart';
import 'package:flutter_data_center/net/dio_utils.dart';
import 'package:get/get.dart';

class GradeAttendanceController extends GetxController {
  // 迟到
  int _late = 0;
  int get late => _late;
  // 总人数
  int _total = 0;
  int get total => _total;
  // 缺卡
  int _missing = 0;
  int get missing => _missing;
  // 早退
  int _leave = 0;
  int get leave => _leave;
  // 学生列表
  List<Persons> _list;
  List<Persons> get list => _list;
  void getGradeStatistics() async {
    _list = [];
    ResponseInfo responseInfo = await DioUtils.instance.getRequest(
      url: HttpHelper.classAttendanceStatistics,
    );
    if (responseInfo.success) {
      var data = responseInfo.data;
      _late = data['late'];
      _total = data["total"];
      _missing = data['missing'];
      _leave = data['leave'];
      for (var item in data['persons']) {
        _list.add(Persons.fromJson(item));
      }

      update();
    }
  }

  // 创建一个map
  Map<String, String> _attendanceType = {
    "card": "打卡",
  };
  Map<String, String> get attendanceType => _attendanceType;

  // 菜单
  List<MenuModel> _menus = [MenuModel("到校", "in"), MenuModel("未到校", "not")];
  List<MenuModel> get menus => _menus;
}
